package com.ymatou.iapi.userservice.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.userservice.parameter.BindEmailBean;
import com.ymatou.iapi.userservice.parameter.UnBindMobileRequestDtoBean;
import com.ymatou.iapi.userservice.parameter.req.CreateUserReq;
import com.ymatou.iapi.userservice.parameter.req.QueryMobileIsbindReq;
import com.ymatou.iapi.userservice.service.QueryMobileIsCanBindCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.database.model.Userinfo;
import com.ymttest.database.sqlwapper.JUserWapper;
import com.ymttest.utils.TestDataManager;
/**
*绑定邮箱Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_QueryMobileIsCanBind{
	private static QueryMobileIsbindReq qmb;
	private static QueryMobileIsCanBindCall qmCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("绑定邮箱");
	}

	@Before
	public void caseUp() {
		qmb=new QueryMobileIsbindReq();
		qmCall=new QueryMobileIsCanBindCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(qmCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryMobileIsCanBind_001() {
		Logger.start(true,"验证可以绑定手机");
		try {
			//创建用户
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			//解绑手机
			UnBindMobileRequestDtoBean ub=new UnBindMobileRequestDtoBean();
			ub.setMobile(cur.getMobile());
			ub.setUserId(uid);
			JUserCallService.UnBindMobileCall(ub);
			
			qmb.setMobile(cur.getMobile());
			qmCall.setData(qmb);
			qmCall.callService();			
			Logger.verifyEquals("true", qmCall.getString("Success"), "验证Success");
			Logger.verifyEquals("200", qmCall.getString("ResponseCode"), "验证ResponseCode");
			Boolean canBind=qmCall.getJsonObject().get("Result").getAsJsonObject().get("canBind").getAsBoolean();
			Logger.verifyEquals(true,canBind, "验证canBind");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryMobileIsCanBind_002() {
		Logger.start(false,"验证不可以绑定手机");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
//			cur.setMobile(null);
			Integer uid = JUserCallService.createUserCall(cur);
			
			qmb.setMobile(cur.getMobile());
			qmCall.setData(qmb);
			qmCall.callService();			
			Logger.verifyEquals("true", qmCall.getString("Success"), "验证Success");
			Logger.verifyEquals("200", qmCall.getString("ResponseCode"), "验证ResponseCode");
			Boolean canBind=qmCall.getJsonObject().get("Result").getAsJsonObject().get("canBind").getAsBoolean();
			Logger.verifyEquals(false,canBind, "验证canBind");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryMobileIsCanBind_003() {
		Logger.start(false,"不输入参数Mobile,失败");
		try {
			qmCall.callService();			
			Logger.verifyEquals("false", qmCall.getString("Success"), "验证Success");
			Logger.verifyEquals("100", qmCall.getString("ResponseCode"), "验证ResponseCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}